﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeBuilder2.Model
{
    class TargetServer
    {
        public string Name { get; set; }
        public string UID { get; set; }
        public string PWD { get; set; }
        public string DataBase { get; set; }

        public override string ToString()
        {
            return "{Name=" + Name + ",UID=" + UID + ",PWD=" + PWD + ",DataBase=" + DataBase + "}";
        }

        public override bool Equals(object obj)
        {
            bool flag = false;
            if (obj is TargetServer)
            {
                flag = this.ToString() == obj.ToString();
            }
            return flag;
        }

        public override int GetHashCode()
        {
            return this.ToString().GetHashCode();
        }

        public static bool operator ==(TargetServer objLeft, TargetServer objRight)
        {
            bool flag = false;
            // 这里需要注意的是不能使用
            // objLeft == null 或者 objRight == null 之类的语句，因为
            // 当前重写的就是 TargetServer 类型的 “==”运算符，如果
            // 使用的话会进入到无限递归中，最终导致堆栈溢出
            if ((object)objLeft == (object)objRight)
            {
                flag = true;
            }
            else if (objLeft is TargetServer && objRight is TargetServer)
            {
                flag = objLeft.Equals(objRight);
            }
            return flag;
        }

        public static bool operator !=(TargetServer objLeft, TargetServer objRight)
        {
            bool flag = !(objLeft == objRight);
            return flag;
        }
    }
}
